package org.jiamandan.com.strategy.enums;


import org.jiamandan.com.constant.ChargeConstant;

public enum ChargeEnum {

    //充电型号
    FACTORY_1(ChargeConstant.Factory.ZD_FACTORY, ChargeConstant.Service.ZD_SERVICE),
    FACTORY_2(ChargeConstant.Factory.YD_FACTORY, ChargeConstant.Service.YD_SERVICE),
    FACTORY_3(ChargeConstant.Factory.YX_FACTORY, ChargeConstant.Service.YX_SERVICE),
    FACTORY_4(ChargeConstant.Factory.JSY_FACTORY, ChargeConstant.Service.JSY_SERVICE);



    private Integer key;

    private String value;

    ChargeEnum(Integer key, String index) {
        this.key = key;
        this.value = index;
    }

    public Integer getKey() {
        return key;
    }

    public void setKey(Integer key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    //通过key-获取value
    public static String getValueByKey(Integer key) {
        for (ChargeEnum contextEnum : ChargeEnum.values()) {
            if (key.equals(contextEnum.key)) {
                return contextEnum.getValue();
            }
        }
        return "";
    }

    //通过vale-获取key
    public static Integer getKeyByValue(String value) {
        for (ChargeEnum contextEnum : ChargeEnum.values()) {
            if (value.equals(contextEnum.value)) {
                return contextEnum.getKey();
            }
        }
        return 0;
    }
}
